﻿using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using StartEAS_API.Utils;
using StartsEAS_API.BLL.Interfaces.IPositionInB;
using StartsEAS_API.Model;
using StartsEAS_API.Model.Models;

namespace StartsEAS_API.Controllers.PositionInContor
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [EnableCors("any")]
    public class PositionInController : ControllerBase
    {
        private readonly IPositionInBLL _positionInBll;
        private readonly StarsEASContext _context;
        public PositionInController(StarsEASContext context, IPositionInBLL loginBll)
        {
            _context = context;
            _positionInBll = loginBll;
        }
        /// <summary>
        /// 获取所有职位信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ResultUtils GetAllPositionIn() {
            try
            {
                return _positionInBll.GetAllPositionIn();
            }
            catch (System.Exception e)
            {
                AppLog.WriteError($"GetAllPositionIn服务器内部异常：{e}", true);
                return new ResultUtils() { code = 500, message = $"服务器内部异常\n{e.Message}" };
            }
        }
    }
}
